package cn.itsource.service.impl;

import cn.itsource.pojo.domain.Employee;
import cn.itsource.mapper.EmployeeMapper;
import cn.itsource.pojo.dto.DepartmentDto;
import cn.itsource.pojo.dto.EmployeeDto;
import cn.itsource.pojo.query.PageQueryWrapper;
import cn.itsource.result.JSONResult;
import cn.itsource.service.IEmployeeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lifan
 * @since 2024-09-10
 */
@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements IEmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;
    @Override
    public JSONResult selectEmployee(PageQueryWrapper<EmployeeDto> employeeDto) {
        List<EmployeeDto> employees;
        if (employeeDto.getKeyword() == null){
            List<Employee> employees1 = employeeMapper.selectList(null);
            return JSONResult.success(employees1);
        }else {
            //条件查询
            employees = employeeMapper.selectEmpl(employeeDto);
        }
        return JSONResult.success(employees);
    }

    @Override
    public void deleteId(Long[] ids) {
        employeeMapper.deleteId(ids);
    }
}
